//输入几年几月，输出他的天数(函数的嵌套调用）
#include<stdio.h>
#include<stdbool.h>
//判断闰年
bool is_leap_year(int year) {
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
		return true;
	} else return false;
}
//给天数
int get_year_month_days(int year, int month) {
	int arr[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int day = arr[month - 1];
	if ((is_leap_year(year)) && month == 2) {
		day++;
	}
	return day;
}
int main() {
	int year = 0, month = 0;
	scanf("%d %d", &year, &month);
	int day = get_year_month_days(year, month);
	printf("%d\n", day);
	return 0;
}

